package org.hawk.gwt.ppc.loader;

import org.hawk.gwt.ppc.Configuration;
import org.hawk.gwt.ppc.GWTModule;
import org.hawk.gwt.ppc.ProcessingUnitsManager;
import org.hawk.gwt.ppc.utils.PreprocessorException;
/**
 * Base interface for all task-related preprocessors.
 * Used and should be registered by {@link ProcessingUnitsManager}. 
 * @author alex.bereznevatiy@gmail.com
 *
 */
public interface ProcessingUnit {
	
	/**
	 * Configures this preprocessor. {@link ProcessingUnitsManager} follows 
	 * his contract to always call this method before run the actual preprocessing.
	 * @param config
	 * @param manager
	 */
	void configure(Configuration config, ProcessingUnitsManager manager);
	
	/**
	 * Do preprocessing for the GWT module xml descriptor.
	 * @param module
	 * @throws PreprocessorException 
	 */
	void processModule(GWTModule module) throws PreprocessorException;
	
	/**
	 * Tries to process single compilation unit.
	 * @param compilationUnit
	 * @throws PreprocessorException in case of processing fails
	 */
	void processCompilationUnit(String compilationUnit) throws PreprocessorException;
	
	/**
	 * Do preprocessing for the GWT module entry point.
	 * @param entryPoint
	 * @param writer 
	 * @throws PreprocessorException 
	 */
	void processEntryPoint(String entryPoint) throws PreprocessorException;
	/**
	 * @param resource
	 * @return <code>true</code> if this preprocessor can and
	 * want to preprocess this resource. Otherwise returns <code>false</code>.
	 */
	boolean acceptResource(String resource);
}
